<template>
  <div id="menu_main">
    <div class="top_menus flex">
      <img class="logo" src="@img/logo.png" alt="云创·汇" />
      <transition name="el-zoom-in-center">
        <span class="title" v-show="!isCollapse">云创·汇</span>
      </transition>
    </div>
    <!--  主菜单 -->
    <el-menu
      :default-active="defaultsMenu"
      :collapse="isCollapse"
      background-color="#001529"
      text-color="#fff"
      :router="true"
      class="spom_menu_default"
      :unique-opened="true"
    >
      <template v-for="(item,index) in menuList">
        <el-submenu v-if="item.list && item.list.length >0" :index="index+''" :key="index">
          <template slot="title">
            <i :class="item.icon"></i>
            <span>{{item.menuName}}</span>
          </template>
          <el-menu-item
            v-for="(ited,ins) in item.list"
            :key="ins"
            :index="ited.menuUrl"
          >{{ited.menuName}}</el-menu-item>
        </el-submenu>
        <el-menu-item v-else :index="item.menuUrl" :key="index">
          <i :class="item.icon"></i>
          <span slot="title">{{item.menuName}}</span>
        </el-menu-item>
      </template>
    </el-menu>
  </div>
</template>

<script>
import { mapState } from 'vuex'

export default {
  data() {
    return {}
  },
  computed: {
    ...mapState({
      menuList: state => state.user.menuList,
      isCollapse: state => state.state.isCollapse
    }),
    defaultsMenu: {
      get() {
        return this.$route.path
      }
    }
  }
}
</script>

<style lang="less" scoped>
#menu_main {
  .spom_menu_default:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
  }
  .top_menus {
    height: 60px;
    font-weight: bold;
    justify-content: center;
    align-items: center;
    background-color: #152738;
    .logo {
      display: inline-block;
      width: 40px;
      height: 40px;
      border-radius: 5px;
    }
    .title {
      margin-left: 10px;
    }
  }

  /deep/ .el-menu {
    border-right: none;
  }
}
</style>
